date_cur=$(date "+%Y%m%d")

homepath="/Users/shangshang/Documents/android-tools/platform-tools/"

echo 当前时间$(date "+%Y-%m-%d %H:%M:%S")

weekofday=$(date +%w)
cur_hour=$(date +%H)

num=$((RANDOM % 300)) #5分钟(300s)后执行
echo "sleep $num"
echo "sleep $((num / 60)) 分钟"

sleep $num
echo 点亮屏幕

echo 当前时间$(date "+%Y-%m-%d %H:%M:%S")
source ~/.bashrc

echo 开始自动签到$(date "+%Y-%m-%d %H:%M:%S")
echo "./adb tcpip 5556 开启wifi 调试"
echo 获取设备列表
$homepath/adb devices
if [ $? -eq 1 ]; then
	$homepath/adb connect 192.168.13.82:5556
fi
$homepath/adb connect 192.168.13.82:5556

echo "等待1秒解锁"
sleep 1
$homepath/adb shell dumpsys window policy | grep "screenState=SCREEN_STATE_ON"
if [ $? -eq 1 ]; then
	echo 屏幕未点亮，唤醒屏幕
	echo 唤醒屏幕
	$homepath/adb shell input keyevent 26
else
	echo 屏幕已点亮

fi

$homepath/adb shell dumpsys window policy | grep "isStatusBarKeyguard=false"
if [ $? -eq 1 ]; then
	echo 屏幕锁定，需要解锁
	$homepath/adb shell input keyevent 82
	echo "第一次滑动解锁，去除充电蒙层"
	$homepath/adb shell input swipe 300 1000 300 500
	sleep 1
	echo "第二次滑动解锁，真正去解锁"
	$homepath/adb shell input swipe 300 1000 300 500
	$homepath/adb shell input keyevent 3
	$homepath/adb shell input keyevent 4
else
	echo 屏幕已解锁

fi

echo 打开gps
$homepath/adb shell settings put secure location_providers_allowed +gps
echo 打开wifi
$homepath/adb shell svc wifi enable

echo 先杀进程
$homepath/adb shell am force-stop cn.wps.moffice_eng

echo 等待4秒
sleep 4

echo 打开wps
# ./adb shell dumpsys activity | grep "moffice" |grep "Activity"
$homepath/adb shell am start -n cn.wps.moffice_eng/cn.wps.moffice.main.StartPublicActivity

echo 等待6秒
sleep 6
echo 点击我的
#$homepath/adb shell input tap 360 1300
$homepath/adb shell input tap 950 2222
echo 等待5秒
sleep 5
echo 点击签到
#$homepath/adb shell input tap 100 880
$homepath/adb shell input tap 1000 150
echo 等待10秒
sleep 10
echo 点击打卡
#$homepath/adb shell input tap 380  780
$homepath/adb shell input tap 550 1050

echo 等待5秒
sleep 5
echo 杀掉进程
$homepath/adb shell am force-stop cn.wps.moffice_eng

echo 关闭屏幕
$homepath/adb shell input keyevent 26
echo 打卡完成
echo 当前时间:$(date "+%Y-%m-%d %H:%M:%S")
echo "\n\n"
